

export abstract class Sort<T> {
    abstract sort (datas: T[]): void;

    // a1 是否小于 a2
    protected less (a1: T, a2: T) {
        try {
            const isLess = a1 < a2;
            return isLess;
        } catch (e) {
            throw new Error('该类型无法比较大小');
        }
    }

    protected exch (arr: T[], i: number, j: number) {
        const temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp; 
    }
}